package com;

import java.util.Objects;

public class Orde implements Comparable<Orde>{
        private long id;
        private int count;
        private double price;

    public Orde() {
    }

    public Orde(long id, int count, double price) {
        this.id = id;
        this.count = count;
        this.price = price;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    @Override
    public String toString() {
        return "Orde{" +
                "id=" + id +
                ", count=" + count +
                ", price=" + price +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Orde orde = (Orde) o;
        return id == orde.id && count == orde.count && Double.compare(orde.price, price) == 0;
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, count, price);
    }

    @Override
    public int compareTo(Orde o) {
        if(this.price<o.price) {
            return 1;
        }else if(this.price>o.price) {
            return -1;
        }else {
            if (this.count>o.count){
                return 1;
            }else if(this.count<o.count){
                return -1;
            }else {
                return 0;
            }
        }
    }
}
